package com.mf.all.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.mf.all.entity.dto.DtoWarehouseArea;
import com.mf.all.entity.req.search.basic.SearchReqWarehouseArea;
import com.mf.all.mapper.MapperWarehouseArea;
import com.mf.all.service.ServiceWarehouseArea;


@Service
public class ImplServiceWarehouseArea extends ServiceImpl<MapperWarehouseArea, DtoWarehouseArea> implements ServiceWarehouseArea {


    @Override
    public LambdaQueryWrapper<DtoWarehouseArea> fillParams(SearchReqWarehouseArea params) {
        final LambdaQueryWrapper<DtoWarehouseArea> wrapper = loadQw();
        if (StringUtils.isNotBlank(params.getKey())) {
            wrapper.and(w -> {
                w.like(DtoWarehouseArea::getAreaName, params.getKey())
                        .or()
                        .like(DtoWarehouseArea::getCode, params.getKey());
            });
        }

        wrapper.eq(ObjectUtils.isNotEmpty(params.getStatus()), DtoWarehouseArea::getStatus, params.getStatus());
        return wrapper;
    }

}